
# Set working directory to main PSD file collection
setwd( "~/java/polydate/" )

# RUN the java code to build dating matrix and list of
# absolutely EVERYONE that has registered.
system( "java -classpath \".:lib/sqlite-jdbc-3.6.20.1.jar\" psd.MatchMaker mydb" )

source( "Rs/allPastData.R" )

# clean up
rm( list=ls() )

# Start from scratch, see what we get!  load.data reads the output of 
# the java file and updates banlist.csv (the list of who is here
# and whether they have paid and what their status is).
source( "Rs/polyDataReadSql.R" )

load.data( INCLUDE_ALL = "NotNo" )

ig = readline( "Now make your table.csv file.  Use the make.table.table function in tableMatcher.R to start.\nHit <return> to proceed.\n> " )


# NOW CHECK IN PEOPLE 
# Go and update the database using django (we hope)
# Check off everyone in the  "here" for everyone that is
# actually present and ready to date.  Hit return to continue when done.
ig = readline( "Hand Edit Ban List and update with those actually checked in.\nHit <return> to continue.\n> " )

# This reloads the data selecting only those who have In=="y".  
load.data( INCLUDE_ALL="In" )

# get demographics for those present.
source( "Rs/demographics.R" )
F = compute.demographics( P )
print( F )

match = readline( "Ready to make matches.  How many rounds of dating?  0 for none.\n> " )
if ( match > 0 ) {	
	source( "Rs/polyMatch.R" )
	trials = readline( "How many random trials should be generated?  More trials will find a better solution, in probability.  Try 10, if you have no idea.\n> " )
	make.matches( match, trials=trials )
}


if ( FALSE ) {
	# testing
	source( "Rs/polyDataReadSql.R" )
	
	system( "java -classpath \".:lib/sqlite-jdbc-3.6.20.1.jar\" psd.MatchMaker  -test testfile.txt testdb" )
	load.data(db="testdb", INCLUDE_ALL="All")

	source( "Rs/polyMatch.R" )
	make.matches( 3, trials=1 )

